/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 * 输入: nums = [5,7,7,8,8,10], target = 8
 输出: 2
 */
 var search = function(nums, target,map = new Map()) {
    for (let i = 0; i < nums.length; i++) {
        let c = nums[i]
        map.set(c, map.has(c) ? map.get(c) + 1 : 1)
        // console.log(map);
        // console.log(map.get(target))
    }
    if (!map.get(target)) { return 0; } else {
    
    return map.get(target) }
};
let res = search( nums = [5,7,7,8,8,10], target = 8)
console.log(res);